<ui:composition  xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:p="http://primefaces.org/ui"
                 template="/template/mainTemplate.xhtml"
                 xmlns:x="http://xpert.com/faces"
                 xmlns:xc="http://java.sun.com/jsf/composite/xpert/components"
                 >
    <ui:param name="title" value="I18N Bean Validation (JSR 303)" />
    <ui:define name="body">
        <h:form>
            <xc:modalMessages/>

            <h:panelGrid columns="3">

                <h:outputLabel value="#{msg['person.name']}:" />
                <p:inputText value="#{personMB.entity.name}" size="40" maxlength="30"/>
                <h:outputText value="@NotBlank" />

                <h:outputLabel value="#{msg['person.rg']}:" />
                <p:inputText value="#{personMB.entity.rg}" size="20" maxlength="30"/>
                <h:outputText value="@NotBlank @Size(max=10)" />

                <h:outputLabel value="#{msg['person.email']}:" />
                <p:inputText value="#{personMB.entity.email}" size="40" maxlength="30"/>
                <h:outputText value="@Email" />

                <h:outputLabel value="#{msg['person.code']}:" />
                <p:inputText value="#{personMB.entity.code}" size="20" maxlength="30"/>
                <h:outputText value="@NotNull @Min(value = 3) @Max(value = 20)" />

                <h:outputLabel value="#{msg['person.salary']}:" />
                <xc:inputNumber value="#{personMB.entity.salary}"/>
                <h:outputText value="@DecimalMin(value = '0.01')" />


            </h:panelGrid>
            <p:separator/>
            <p:commandButton process="@form" update="@form" value="Save" />

        </h:form>

        <h3>Source</h3>
        <p:tabView>
            <p:tab title="i18nBeanValidation.xhtml">
                <pre name="code" class="xml">
                        &lt;h:form&gt;
                            &lt;xc:modalMessages/&gt;

                            &lt;h:panelGrid columns=&quot;3&quot;&gt;

                                &lt;h:outputLabel value=&quot;\#{msg['person.name']}:&quot; /&gt;
                                &lt;p:inputText value=&quot;\#{personMB.entity.name}&quot; size=&quot;40&quot; maxlength=&quot;30&quot;/&gt;
                                &lt;h:outputText value=&quot;@NotBlank&quot; /&gt;

                                &lt;h:outputLabel value=&quot;\#{msg['person.rg']}:&quot; /&gt;
                                &lt;p:inputText value=&quot;\#{personMB.entity.rg}&quot; size=&quot;20&quot; maxlength=&quot;30&quot;/&gt;
                                &lt;h:outputText value=&quot;@NotBlank @Size(max=10)&quot; /&gt;

                                &lt;h:outputLabel value=&quot;\#{msg['person.email']}:&quot; /&gt;
                                &lt;p:inputText value=&quot;\#{personMB.entity.email}&quot; size=&quot;40&quot; maxlength=&quot;30&quot;/&gt;
                                &lt;h:outputText value=&quot;@Email&quot; /&gt;

                                &lt;h:outputLabel value=&quot;\#{msg['person.code']}:&quot; /&gt;
                                &lt;p:inputText value=&quot;\#{personMB.entity.code}&quot; size=&quot;20&quot; maxlength=&quot;30&quot;/&gt;
                                &lt;h:outputText value=&quot;@NotNull @Min(value = 3) @Max(value = 20)&quot; /&gt;

                                &lt;h:outputLabel value=&quot;\#{msg['person.salary']}:&quot; /&gt;
                                &lt;xc:inputNumber value=&quot;\#{personMB.entity.salary}&quot;/&gt;
                                &lt;h:outputText value=&quot;@DecimalMin(value = '0.01')&quot; /&gt;


                            &lt;/h:panelGrid&gt;
                            &lt;p:separator/&gt;
                            &lt;p:commandButton process=&quot;@form&quot; update=&quot;@form&quot; value=&quot;Save&quot; /&gt;

                        &lt;/h:form&gt;

                </pre>
            </p:tab>
            <ui:include src="/views/common/java/person.xhtml"/>
            <p:tab title="xpert-config.xml">
                Create <b>xpert-config.xml</b> in WEB-INF and define your resource-bundle path:
                <pre name="code" class="xml">
                &lt;xpert-config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
                    &lt;resource-bundle&gt;bundles.messages&lt;/resource-bundle&gt;
                &lt;/xpert-config&gt;
                </pre>
            </p:tab>
            <p:tab title="faces-config.xml">
                <h3>Override Bean Validation</h3>
                <pre name="code" class="xml">
                    &lt;validator&gt;
                        &lt;validator-class&gt;com.xpert.core.validation.BeanValidator&lt;/validator-class&gt;
                        &lt;validator-id&gt;javax.faces.Bean&lt;/validator-id&gt;
                    &lt;/validator&gt;
                </pre>
            </p:tab>
            <p:tab title="validation.xml">
                <h3>Create a Custom Interpolator in META-INF/validation.xml</h3>
                <pre name="code" class="xml">
                   &lt;validation-config
                        xmlns=&quot;http://jboss.org/xml/ns/javax/validation/configuration&quot;
                        xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
                        xsi:schemaLocation=&quot;http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd&quot;&gt;
                            &lt;message-interpolator&gt;com.xpert.i18n.CustomInterpolator&lt;/message-interpolator&gt;
                    &lt;/validation-config&gt;  
                </pre>
            </p:tab>
            <p:tab title="messages.properties">
                <h3>en - English</h3>
                <pre name="code" class="java">
                person.search=Search Person
                person.create=Create Person
                person.name=Name
                person.cpf=CPF
                person.code=Code
                person.status=Status
                person.group=Group
                person.group2=Group 2
                person.birthday=Birthday
                person.rg=RG
                person.salary=Salary
                person.email=Email
                person.permissions=Permissions
                </pre>
                <h3>pt_BR - Português</h3>
                <pre name="code" class="java">
                person.name=Nome
                person.cpf=CPF
                person.code=Código
                person.status=Status
                person.group=Grupo
                person.group2=Grupo 2
                person.birthday=Data de Nascimento
                person.rg=RG
                person.salary=Salário
                person.email=Email
                person.permissions=Permissões
                </pre>
            </p:tab>
        </p:tabView>

    </ui:define>
</ui:composition>
